using APP.HELPER.Data.Helper;
using DevExpress.XtraEditors;
using System;
using System.Data;
using System.Data.SqlClient;
namespace Extra.ERP
{
    public class SYS_USER
    {
        private bool m_Active;
        private string m_BranchCode;
        private string m_DepartmentCode;
        private string m_Description;
        private string m_Email;
        private string m_EmployeeCode;
        private string m_Group_ID;
        private string m_GroupCode;
        private int m_Management;
        private string m_PartID;
        private string m_Password;
        private string m_UserID;
        private string m_UserName;

        public SYS_USER()
        {
            this.m_UserID = "";
            this.m_UserName = "";
            this.m_Password = "";
            this.m_Group_ID = "";
            this.m_Email = "";
            this.m_Description = "";
            this.m_PartID = "";
            this.m_Management = 0;
            this.m_BranchCode = "";
            this.m_DepartmentCode = "";
            this.m_GroupCode = "";
            this.m_EmployeeCode = "";
            this.m_Active = true;
        }

        public SYS_USER(string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string str = MyLogin.CreatePassword(UserName, Password);
            this.m_UserID = UserID;
            this.m_UserName = UserName;
            this.m_Password = str;
            this.m_Group_ID = Group_ID;
            this.m_Email = Email;
            this.m_Description = Description;
            this.m_PartID = PartID;
            this.m_Management = Management;
            this.m_BranchCode = BranchCode;
            this.m_DepartmentCode = DepartmentCode;
            this.m_GroupCode = GroupCode;
            this.m_EmployeeCode = EmployeeCode;
            this.m_Active = Active;
        }

        public void AddBranchGridLookupEdit(GridLookUpEdit gridlookup)
        {
            DataTable branchList = new DataTable();
            branchList = this.GetBranchList();
            gridlookup.Properties.DataSource = branchList;
            gridlookup.Properties.DisplayMember = "BranchName";
            gridlookup.Properties.ValueMember = "BranchCode";
        }

        public void AddDepartmentGridLookupEdit(GridLookUpEdit gridlookup, string BranchCode)
        {
            DataTable listByBranch = new DataTable();
            listByBranch = this.GetListByBranch(BranchCode);
            gridlookup.Properties.DataSource = listByBranch;
            gridlookup.Properties.DisplayMember = "DepartmentName";
            gridlookup.Properties.ValueMember = "DepartmentCode";
        }

        public void AddEmployeeGridLookupEdit(GridLookUpEdit gridlookup)
        {
            DataTable listEmployee = new DataTable();
            listEmployee = this.GetListEmployee(0, "");
            gridlookup.Properties.DataSource = listEmployee;
            gridlookup.Properties.DisplayMember = "EmployeeCode";
            gridlookup.Properties.ValueMember = "EmployeeCode";
        }

        public void AddGroupGridLookupEdit(GridLookUpEdit gridlookup, string DepartmentCode)
        {
            DataTable listByDepartment = new DataTable();
            listByDepartment = this.GetListByDepartment(DepartmentCode);
            gridlookup.Properties.DataSource = listByDepartment;
            gridlookup.Properties.DisplayMember = "GroupName";
            gridlookup.Properties.ValueMember = "GroupCode";
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { this.m_UserID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Delete", myParams, myValues);
        }

        public string Delete(string UserID)
        {
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string UserID)
        {
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "SYS_USER_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string UserID)
        {
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "SYS_USER_Delete", myParams, myValues);
        }

        public bool Exist(string UserID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public bool ExistEmployeeCode(string EmployeeCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_Get_By_EmployeeCode", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public bool ExistEmployeeCode(string EmployeeCode, string UserName)
        {
            bool hasRows = false;
            this.Get_UserName(UserName);
            string employeeCode = this.m_EmployeeCode;
            string[] myParams = new string[] { "@NewEmployeeCode", "@OldEmployeeCode" };
            object[] myValues = new object[] { EmployeeCode, employeeCode };
            SqlHelper helper = new SqlHelper
            {
                CommandType = CommandType.Text
            };
            SqlDataReader reader = helper.ExecuteReader("Select * From [SYS_USER]\r\n Where \r\n   [SYS_USER].EmployeeCode  = @NewEmployeeCode\r\nand [SYS_USER].EmployeeCode  <> @OldEmployeeCode", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string UserID)
        {
            string str = "";
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string UserID)
        {
            string str = "";
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "SYS_USER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string UserID)
        {
            string str = "";
            string[] myParams = new string[] { "@UserID" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "SYS_USER_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get_UserName(string UserID)
        {
            string str = "";
            string[] myParams = new string[] { "@UserName" };
            object[] myValues = new object[] { UserID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_Get_By_UserName", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetBranchList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_BRANCH_GetList");
        }

        public DataTable GetEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_EMPLOYEE_Get", myParams, myValues);
        }

        public string GetEmployeeCode(string EmployeeCode)
        {
            string str = "";
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_Get_By_EmployeeCode", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("SYS_USER_GetList");
        }

        public DataTable GetList(string Group_ID)
        {
            string[] myParams = new string[] { "@Group_ID" };
            object[] myValues = new object[] { Group_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("SYS_USER_GetList_By_Group", myParams, myValues);
        }

        public DataTable GetListByBranch(string BranchCode)
        {
            string[] myParams = new string[] { "@BranchCode" };
            object[] myValues = new object[] { BranchCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_DEPARTMENT_GetListByBranch", myParams, myValues);
        }

        public DataTable GetListByDepartment(string DepartmentCode)
        {
            string[] myParams = new string[] { "@DepartmentCode" };
            object[] myValues = new object[] { DepartmentCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_GROUP_GetListByDepartment", myParams, myValues);
        }

        public DataTable GetListEmployee(int Level, string Code)
        {
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { Level, Code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_EMPLOYEE_GetAllList", myParams, myValues);
        }

        public string GetUserName(string UserName)
        {
            string str = "";
            string[] myParams = new string[] { "@UserName" };
            object[] myValues = new object[] { UserName };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("SYS_USER_GetUserName", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_UserID = Convert.ToString(reader["UserID"]);
                    this.m_UserName = Convert.ToString(reader["UserName"]);
                    this.m_Password = Convert.ToString(reader["Password"]);
                    this.m_Group_ID = Convert.ToString(reader["Group_ID"]);
                    this.m_Email = Convert.ToString(reader["Email"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_PartID = Convert.ToString(reader["PartID"]);
                    this.m_Management = Convert.ToInt32(reader["Management"]);
                    this.m_BranchCode = Convert.ToString(reader["BranchCode"]);
                    this.m_DepartmentCode = Convert.ToString(reader["DepartmentCode"]);
                    this.m_GroupCode = Convert.ToString(reader["GroupCode"]);
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_Active = Convert.ToBoolean(reader["Active"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { this.m_UserID, this.m_UserName, this.m_Password, this.m_Group_ID, this.m_Email, this.m_Description, this.m_PartID, this.m_Management, this.m_BranchCode, this.m_DepartmentCode, this.m_GroupCode, this.m_EmployeeCode, this.m_Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { this.m_UserID, this.m_UserName, this.m_Password, this.m_Group_ID, this.m_Email, this.m_Description, this.m_PartID, this.m_Management, this.m_BranchCode, this.m_DepartmentCode, this.m_GroupCode, this.m_EmployeeCode, this.m_Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "SYS_USER_Insert", myParams, myValues);
        }

        public string Insert(string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "SYS_USER_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "SYS_USER_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("SYS_USER", "UserID", "US");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { this.m_UserID, this.m_UserName, this.m_Password, this.m_Group_ID, this.m_Email, this.m_Description, this.m_PartID, this.m_Management, this.m_BranchCode, this.m_DepartmentCode, this.m_GroupCode, this.m_EmployeeCode, this.m_Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Update", myParams, myValues);
        }

        public string Update(string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string str = MyLogin.CreatePassword(UserName, Password);
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("SYS_USER_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "SYS_USER_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string UserID, string UserName, string Password, string Group_ID, string Email, string Description, string PartID, int Management, string BranchCode, string DepartmentCode, string GroupCode, string EmployeeCode, bool Active)
        {
            string[] myParams = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] myValues = new object[] { UserID, UserName, Password, Group_ID, Email, Description, PartID, Management, BranchCode, DepartmentCode, GroupCode, EmployeeCode, Active };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "SYS_USER_Update", myParams, myValues);
        }

        public string UpdateNopass()
        {
            string[] strArray = new string[] { "@UserID", "@UserName", "@Password", "@Group_ID", "@Email", "@Description", "@PartID", "@Management", "@BranchCode", "@DepartmentCode", "@GroupCode", "@EmployeeCode", "@Active" };
            object[] objArray = new object[] { this.m_UserID, this.m_UserName, this.m_Password, this.m_Group_ID, this.m_Email, this.m_Description, this.m_PartID, this.m_Management, this.m_BranchCode, this.m_DepartmentCode, this.m_GroupCode, this.m_EmployeeCode, this.m_Active };
            string commandText = string.Concat(new object[] { 
                "UPDATE [SYS_USER] SET [UserName] = N'", this.m_UserName, "',[Group_ID] =N'", this.m_Group_ID, "',[Email]=N'", this.m_Email, "',[Description]=N'", this.m_Description, "' ,[PartID] = N'", this.m_PartID, "' ,[Management] = ", this.m_Management, " ,[BranchCode] = N'", this.m_BranchCode, "' ,[DepartmentCode] = N'", this.m_DepartmentCode, 
                "' ,[GroupCode] = N'", this.m_GroupCode, "' ,[EmployeeCode] = N'", this.m_EmployeeCode, "',[Active] = ", this.m_Active ? 1 : 0, " Where [UserID] =N'", this.m_UserID, "'"
             });
            SqlHelper helper = new SqlHelper
            {
                CommandType = CommandType.Text
            };
            return helper.ExecuteNonQuery(commandText);
        }

        public bool Active
        {
            get
            {
                return this.m_Active;
            }
            set
            {
                this.m_Active = value;
            }
        }

        public string BranchCode
        {
            get
            {
                return this.m_BranchCode;
            }
            set
            {
                this.m_BranchCode = value;
            }
        }

        public string DepartmentCode
        {
            get
            {
                return this.m_DepartmentCode;
            }
            set
            {
                this.m_DepartmentCode = value;
            }
        }

        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        public string Email
        {
            get
            {
                return this.m_Email;
            }
            set
            {
                this.m_Email = value;
            }
        }

        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        public string Group_ID
        {
            get
            {
                return this.m_Group_ID;
            }
            set
            {
                this.m_Group_ID = value;
            }
        }

        public string GroupCode
        {
            get
            {
                return this.m_GroupCode;
            }
            set
            {
                this.m_GroupCode = value;
            }
        }

        public int Management
        {
            get
            {
                return this.m_Management;
            }
            set
            {
                this.m_Management = value;
            }
        }

        public string PartID
        {
            get
            {
                return this.m_PartID;
            }
            set
            {
                this.m_PartID = value;
            }
        }

        public string Password
        {
            get
            {
                return this.m_Password;
            }
            set
            {
                this.m_Password = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class SYS_USER";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public string UserID
        {
            get
            {
                return this.m_UserID;
            }
            set
            {
                this.m_UserID = value;
            }
        }

        public string UserName
        {
            get
            {
                return this.m_UserName;
            }
            set
            {
                this.m_UserName = value;
            }
        }
    }

}
